package chai.ningning.status;

import java.util.concurrent.TimeUnit;

public class ThreadStatusTest2 {

    static class MyThread extends Thread{
        @Override
        public void run() {
            Thread current = Thread.currentThread();
            System.out.println(current +" : "+ current.getState());
            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(current +" : "+ current.getState());
        }
    }

    public static void main(String[] args) throws InterruptedException {

        MyThread myThread = new MyThread();
        System.out.println(myThread + " : " + myThread.getState());
        myThread.start();

        TimeUnit.SECONDS.sleep(2);
        System.out.println(myThread + " : " +myThread.getState());
    }
}
